import request from '../../utils/request/SPNrequest'

 export interface shopData {
    "id": number,
    "userId": string,
    "skuId": number,
    "cartPrice": number,
    "skuNum": number,
    "imgUrl": string,
    "skuName": string,
    "isChecked": number,
    "createTime": string,
    "operateTime": string,
    "isOrdered": number,
    "orderTime": null,
    "sourceType": string,
    "sourceId": number,
    "skuPrice": number,
    "couponInfoList": null
}

export type ShopListData = shopData[]
/**
 * @description 获取购物车列表
 * @returns Promise
 */
export const reqcartList = () => {
    return request.get<any, ShopListData>('/api/cart/cartList')
}
/**
 * @description 切换商品选中状态
 * @param skuID 
 * @param isChecked 
 * @returns 
 */
export const reqCheckOneCart =(skuID:number,isChecked:number)=>{
    return request.get<any,null>(`/api/cart/checkCart/${skuID}/${isChecked}`)
}

/**
 * @description 商品全选
 * @param isChecked 
 * @returns 
 */
export const reqBatchCheckAllCart =(isChecked:number,skuIdList:any)=>{
    return request.post<any,null>(`/api/cart/batchCheckCart/${isChecked}`,skuIdList)
}

/**
 * @description 删除单个商品
 * @param skuId 
 * @returns 
 */
export const reqdeleteOneCart =(skuId:number)=>{
    return request.delete<any,null>(`/api/cart/deleteCart/${skuId}`)
}

/**
 * @description 加入购物车
 * @param skuId 
 * @param skuNum 
 * @returns 
 */
export const reqAddToCart =(skuId:number,skuNum:number)=>{
    return request.post<any,null>(`/api/cart/addToCart/${skuId}/${skuNum}`)
}